﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace Kinect.Toolbox
{
    /// <summary>
    /// Vector2 represents a two-dimensional coordinate (x,y) vector
    /// with different operators +,-,*,/
    /// The following class was provided by the book 
    /// Microsoft.Press.Programming.with.the.Kinect.for.Windows.Software.Development.Kit.Sep.2012
    /// </summary>
    [Serializable]
    public struct Vector2
    {
        public float X;
        public float Y;
        public static Vector2 Zero
        {
            get
            {
                return new Vector2(0, 0);
            }
        }
        public Vector2(float x, float y)
        {
            X = x;
            Y = y;
        }
        public float Length
        {
            get
            {
                return (float)Math.Sqrt(X * X + Y * Y);
            }
        }
        public static Vector2 operator -(Vector2 left, Vector2 right)
        {
            return new Vector2(left.X - right.X, left.Y - right.Y);
        }
        public static Vector2 operator +(Vector2 left, Vector2 right)
        {
            return new Vector2(left.X + right.X, left.Y + right.Y);
        }
        public static Vector2 operator *(Vector2 left, float value)
        {
            return new Vector2(left.X * value, left.Y * value);
        }
        public static Vector2 operator *(float value, Vector2 left)
        {
            return left * value;
        }
        public static Vector2 operator /(Vector2 left, float value)
        {
            return new Vector2(left.X / value, left.Y / value);
        }
    }
}